package Week5.J0517;

import java.util.Scanner;

public class 消减整数_xv {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int ret = 0;
            int a = 1;
            while (num != 0) {
                num -= a;
                ret++;
                if (num % (2 * a) == 0) {
                    a *= 2;
                }
            }
            System.out.println(ret);
        }
    }
}
